// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SetCharacterEncodingFilter.java

package com.iphaeton.common.filter;

import java.io.IOException;
import javax.servlet.*;
import org.apache.log4j.Logger;

public class SetCharacterEncodingFilter
    implements Filter
{

    public SetCharacterEncodingFilter()
    {
        encoding = null;
        filterConfig = null;
        flag = true;
    }

    public void init(FilterConfig filterConfig)
        throws ServletException
    {
        this.filterConfig = filterConfig;
        encoding = filterConfig.getInitParameter("encoding");
        String fValue = filterConfig.getInitParameter("flag");
        if(fValue == null)
            flag = true;
        else
        if(fValue.equalsIgnoreCase("true"))
            flag = true;
        else
            flag = false;
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException
    {
        if(flag || request.getCharacterEncoding() == null)
        {
            String encoding = this.encoding;
            if(encoding != null)
                request.setCharacterEncoding(encoding);
            logger.info("\u5C06\u5B57\u7B26\u7F16\u7801\u65B9\u5F0F\u8BBE\u7F6E\u4E3A:" + encoding);
        }
        chain.doFilter(request, response);
    }

    public void destroy()
    {
        encoding = null;
        filterConfig = null;
    }

    protected String encoding;
    protected FilterConfig filterConfig;
    protected boolean flag;
    private static Logger logger;
    static Class class$0; /* synthetic field */

    static 
    {
        logger = Logger.getLogger(com.iphaeton.common.filter.SetCharacterEncodingFilter.class.getName());
    }
}
